var WxParse = require('../../wxParse/wxParse.js');
//获取应用实例
const app = getApp()
Page({
	data: {
		imgpath:app.setting.apiimgpath,
		activeList:'',
		yesActity:true,
		noActity:false,
		colorShow:true,
		isJoin:''
	},
	onLoad:function(option){
		var that = this;
		//获取活动详情
		app.request('/api/Member/getActiveInfo', {challengeid:option.acid}, function(res){
			if(res.code == '0'){
				WxParse.wxParse('content', 'html', res.data.content, that, 5);
				that.setData({
					activeList:res.data,
					isJoin:res.data.point==0 ? '无门槛参与' : '积分报名参与'
				})
				if(res.data.status == 1 ){
					//报名中
					that.setData({
						colorShow:true,
						yesActity:true,
						noActity:false
					})
					if(res.data.is_partake == 1){
						that.setData({
							colorShow:false,
							yesActity:false,
							noActity:true,
							isJoin:'已参与'
						})
					}
				}else if(res.data.status == 2){
					//进行中
					that.setData({
						colorShow: false,
						yesActity: false,
						noActity: true
					})
					if(res.data.is_partake == 1){
						that.setData({
							isJoin:'已参与'
						})
					}else{
						that.setData({
							isJoin:'未参与'
						})
					}
				}else{
					//已结束
					that.setData({
						colorShow: false,
						yesActity: false,
						noActity: true
					})
					if(res.data.is_partake == 1){
						that.setData({
							isJoin:'活动已结束'
						})
					} else {
						that.setData({
							isJoin:'已过期'
						})
					}
				}
			}
		});
	},
	gotoActiv:function(event){
		let that = this
		wx.requestSubscribeMessage({
		    tmplIds:['AR9e6eZypCC0tY-6C5V0VUs8zjrU6GjTBjbnDTeJW2w'],
		    success(res){
				
			},
			fail(res){

			}
		})
		wx.navigateTo({
			 url:'/pages/enrollin/enrollin?acid=' + that.data.activeList.challenge_id
		})
	},
	onShareAppMessage(res){ 
		return{
			title:this.data.activeList.title,
			path:'/pages/bannerdetail/bannerdetail?acid='+this.data.activeList.challenge_id,
			imageUrl:this.data.imgpath + '/' + this.data.activeList.pic
		}
	}
})